package ${package}.backstage.controller;

import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import ${package}.backstage.service.${ClassName}Service;
import ${package}.common.annotation.RequiresPermissionDesc;
import ${package}.common.enums.PermissionType;
import ${package}.common.model.PageResponse;
import ${package}.common.model.RemoteResponse;
import ${package}.common.model.User;
import ${package}.dao.entity.${moduleName}.${ClassName};
import ${package}.dao.vo.${moduleName}.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
* ${tableComment} controller
*
* @author ${author} ${email}
* @since ${version} ${date}
*/
@Api(tags = "${tableComment}")
@RestController
@RequestMapping("backstage/${className}")
@RequiresPermissions("${className}")
@RequiresPermissionDesc(title = "${tableComment}管理", type = PermissionType.MenuItem, sort = 2)
public class ${ClassName}Controller {
    @Autowired
    private ${ClassName}Service ${className}Service;

    /**
     * 查询${tableComment}列表
     */
    @ApiOperation("查询${tableComment}列表")
    @RequestMapping(value = "/list",method = RequestMethod.POST)
    @RequiresPermissions("${className}_query")
    @RequiresPermissionDesc(title = "${tableComment}分页", type = PermissionType.Index, sort = 1)
    public RemoteResponse<PageResponse<${ClassName}Result>> list(@RequestBody ${ClassName}SearchParam searchVO){
        PageResponse<${ClassName}Result> page = ${className}Service.select${ClassName}List(searchVO);
        return RemoteResponse.success(page);
    }

    /**
     * 获取${tableComment}详细信息
     */
    @ApiOperation("获取${tableComment}详细信息")
    @RequestMapping(value = "/detail",method = RequestMethod.GET)
    @RequiresPermissions("${className}_details")
    @RequiresPermissionDesc(title="${tableComment}详情",type=PermissionType.Detail,sort=3)
    public RemoteResponse<${ClassName}> getInfo(@RequestParam("id") Long id){
        return RemoteResponse.success(${className}Service.select${ClassName}ById(id));
    }

    /**
     * 新增${tableComment}
     */
    @ApiOperation("新增${tableComment}")
    @RequestMapping(value = "add",method = RequestMethod.POST)
    @RequiresPermissions("${className}_add")
    @RequiresPermissionDesc(title="添加${tableComment}",type=PermissionType.Add,sort=4)
    public RemoteResponse add(@RequestBody ${ClassName}CreateParam createVO,User user){
        ${className}Service.insert${ClassName}(createVO,user);
        return RemoteResponse.success();
    }

    /**
     * 修改${tableComment}
     */
    @ApiOperation("修改${tableComment}")
    @RequestMapping(value = "edit",method = RequestMethod.POST)
    @RequiresPermissions("${className}_edit")
    @RequiresPermissionDesc(title="编辑${tableComment}",type=PermissionType.Edit,sort=5)
    public RemoteResponse edit(@RequestBody ${ClassName}UpdateParam updateVO,User user){
        ${className}Service.update${ClassName}(updateVO,user);
        return RemoteResponse.success();
    }

    /**
     * 删除${tableComment}
     */
    @ApiOperation("删除${tableComment}")
    @RequestMapping(value = "/del",method = RequestMethod.GET)
    @RequiresPermissions("${className}_del")
    @RequiresPermissionDesc(title="删除${tableComment}",type=PermissionType.Del,sort=6)
    public RemoteResponse remove(@RequestParam String id){
        ${className}Service.delete${ClassName}ByIds(id);
        return RemoteResponse.success();
    }
}
